using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Beta_fundies_controls_misc_SiteHeader : Controls.DataManagerArchiveControl
{
    private DateTime ArchiveDate
    {
        get
        {
            DateTime archive;
            if (Helpers.QueryStringHelper.TryGetDateTime("archive", out archive))
            {
                return archive;
            }
            else
            {
                return DateTime.Today;
            }
        }
    }

    protected override void ItemChanged()
    {
        if (CurrentArchive != null)
        {
            mviewHeader.SetActiveView(viewHeader);
            lnkArchives.NavigateUrl = String.Format("~/fundies/archives.aspx?archive={0}", CurrentArchive.ID);

            lnkLastMonth.Text = ArchiveDate.AddMonths(-1).ToString("MMMM yyyy");
            lnkLastMonth.NavigateUrl = String.Format("~/fundies/default.aspx?date={0:yyyy/MM}&archive={1}", ArchiveDate.AddMonths(-1), CurrentArchive.ID);

            lnkCurrentMonth.Text = ArchiveDate.ToString("MMMM yyyy");
            lnkCurrentMonth.NavigateUrl = String.Format("~/fundies/default.aspx?date={0:yyyy/MM}&archive={1}", ArchiveDate, CurrentArchive.ID);

            lnkRandom.NavigateUrl = String.Format("~/fundies/random.aspx?archive={0}", CurrentArchive.ID);
            lnkTop100.NavigateUrl = String.Format("~/fundies/top100.aspx?archive={0}", CurrentArchive.ID);

            lnkLatest.NavigateUrl = String.Format("~/fundies/latestcomments.aspx?archive={0}", CurrentArchive.ID);
        }
        else
        {
            mviewHeader.SetActiveView(viewError);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DAL.Archive myArchive = GetItemFromQueryString();
            if (myArchive == null)
            {
                myArchive = DAL.Archives.Item(1);
            }
            CurrentArchive = myArchive;
        }
    }
}
